// app/api/notifications/[id]/delete/route.ts import { NextRequest, NextResponse } from 'next/server'; import { getServerSession } from 'next-auth'; import { authOptions } from "@/app/api/auth/[...nextauth]/route" import { deleteNotification } from '@/lib/notification/service'; export async function DELETE( request: NextRequest, { params }: { params: { id: string } } ) { try { const session = await getServerSession(authOptions); if (!session?.user?.id) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } const deletedNotification = await deleteNotification(params.id, session.user.id); if (!deletedNotification) { return NextResponse.json( { error: 'Notification not found' }, { status: 404 } ); } return NextResponse.json({ success: true }); } catch (error) { console.error('Error deleting notification:', error); return NextResponse.json( { error: 'Failed to delete notification' }, { status: 500 } ); } }